﻿<%@ Page Title="Đặt vé" Language="C#" MasterPageFile="~/template.master" AutoEventWireup="true" CodeFile="datve.aspx.cs" Inherits="datve" %>

<%@ Register src="khanhdaiA.ascx" tagname="khanhdaiA" tagprefix="uc1" %>
<%@ Register src="khanhdaiB.ascx" tagname="khanhdaiB" tagprefix="uc2" %>
<%@ Register src="khanhdaiC.ascx" tagname="khanhdaiC" tagprefix="uc3" %>
<%@ Register src="khanhdaiTH.ascx" tagname="khanhdaiTH" tagprefix="uc4" %>
<%@ Register src="khanhdaiV.ascx" tagname="khanhdaiV" tagprefix="uc5" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <style type="text/css" runat="server" ID="Style" Visible="True">
        .right {
            display: none;
        }
        .content {
            width: 860px;
        }
        .booking{ display: none;}
    </style>
    <script language="javascript">
        $(function () {
            $(".gheSelected").click(function () {
                var id = $(this).attr('id');
                var cur = $(this).next('img:first').attr('src');
                cur = cur.split("/")[cur.split("/").length - 1];

                var list = $(".booking").val();
                if (cur == "con_trong.png") {
                    alert("Ghế " + id + " đã được chọn, vui lòng chọn ghế khác");
                } else if (cur == "dang_chon.png") {
                    $(this).next('img:first').attr('src', 'images/ghe/khu_vuc_khac.png');
                    $("#listGhe").find("#" + id + "").remove();
                    if (list != "")
                        list = removeFromList(list, id);
                } else {
                    $(this).next('img:first').attr('src', 'images/ghe/dang_chon.png');
                    $("#listGhe").append("<a id=\"" + id + "\" class=\"btn btn-primary disabled\">" + id + "</a> ");
                    list += (list != "") ? "," + id : id;
                }
                $(".booking").val(list);
            });

            $("#submitBtn").click(function () {
                var booking = $(".booking").val();
                if (booking.length == 0) {
                    alert("Vui lòng chọn ghế ngồi!");
                } else {
                    $("#submitBooking").val(1);
                    $("form:first").submit();
                }
            });
        });

        
        function removeFromList(list,val) {
            var ele = [];
            list = list.split(",");
            for(i=0; i<list.length; i++) {
                if (list[i] != val)
                    ele.push(list[i]);
            }
            return ele.toString(",");
        }
    </script>
    <asp:Label ID="Message" runat="server" Text="Label" Visible="False" CssClass="LichDienMessage alert alert-error"></asp:Label>
    
    <div runat="server" ID="MainContent">
    <div style="text-align: center;">
        <asp:Image ID="Image1" runat="server" Width="500px" ImageUrl="~/images/ghe/sankhau.png" />
    </div>
    <div style="text-align: center;margin: 15px 0;">
        <asp:Label ID="Label1" runat="server" Text="Chọn khán đài: "></asp:Label>
        <asp:DropDownList ID="DropDownList1" runat="server" 
            AutoPostBack="true"
            onselectedindexchanged="DropDownList1_SelectedIndexChanged" >
        </asp:DropDownList>
    </div>
    <div style="text-align: center;width: 70%;margin: 0 auto;">
        <table class="table" style="width: 100%">
            <tr>
                <td style="width: 20%"><span alert alert-info>Các ghế đã chọn</span></td>
                <td><div id="listGhe" style="line-height: 35px;"></div>
                    
                </td>
                <td style="width: 10%;">
                    <input name="booking" type="hidden" class="booking" value="" />
                    <input name="submitBooking" id="submitBooking" type="hidden" class="booking" value="0" />
                    <input type="button" id="submitBtn" class="btn" value="Đặt vé"/>
                </td>
            </tr>
        </table>

    </div>
    <div class="thumbnail">
        
        <uc1:khanhdaiA ID="khanhdaiA" runat="server" Visible="False" />
        <uc2:khanhdaiB ID="khanhdaiB" runat="server" Visible="False" />
        <uc3:khanhdaiC ID="khanhdaiC" runat="server" Visible="False" />
        <uc4:khanhdaiTH ID="khanhdaiTH" runat="server" Visible="False" />
        <uc5:khanhdaiV ID="khanhdaiV" runat="server" Visible="False" />
        
    </div>
    </div>
</asp:Content>

